#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
int main()
{
	char s[20][20] = { 0 };
	int m;
	while (scanf("%d", &m) != EOF)
	{


		for (int i = 0; i < m; i++)
		{
			for (int j = 0; j < m; j++)
			{
				if (i == 0 || i == m - 1 || j == 0 || j == m - 1)
				{
					s[i][j] = '*';
				}
				else
				{
					s[i][j] = ' ';
				}
			}
		}
		for (int i = 0; i < m; i++)
		{
			for (int j = 0; j < m; j++)
			{
				printf("%c ", s[i][j]);
			}
			printf("\n");
		}
	}
	return 0;
}